Imports System.Collections
Imports SchemaCodeGen

Partial Class pages_entitys_usercontrols_UCEntity : Inherits UserControl

#Region "Members"
    Private m_entity As CEntity
    Private m_sortedList As IList
#End Region

#Region "Interface"
    Public Sub Display(ByVal [entity] As CEntity, sortedList as IList)
        If Parent.Controls.Count Mod 2 = 0 Then row.Attributes.Add("class", "alt_row")

        m_entity = [entity]
        m_sortedList = sortedList

        With m_entity
			litNumber.Text = CStr(sortedList.IndexOf(m_entity) + 1)
			litOwner.Text = .UserName
			litEntityConnectionId.Text = .Connection.ConnectionName
            lnkEntityClassName.Text =  CStr(IIF(.EntityClassName.Length = 0, "...", .EntityClassName))
            lnkEntityClassName.NavigateUrl = CSitemap.EntityEdit(.EntityId)
            litEntityTableName.Text = .EntityTableName
            litEntitySchemaName.Text = .EntitySchemaName
            chkEntityIsCached.Checked = .EntityIsCached
            chkEntityIsAudited.Checked = .EntityIsAudited
            litEntityViewName.Text = .EntityViewName
            litEntityOrderByColumns.Text = .EntityOrderByColumns
            litEntityOrdinalColumn.Text = .EntityOrdinalColumn
            litEntityCreatedColumn.Text = .EntityCreatedColumn
            litEntityModifiedColumn.Text = .EntityModifiedColumn
			litEntityFilterColumns.Text = .EntityFilterColumns

			litEntityCreated.Text = CUtilities.Timespan(.EntityCreated)
			litEntityCreated.Text = CUtilities.Timespan(.EntityCreated)
			litEntityModified.ToolTip = CUtilities.LongDateTime(.EntityModified)
			litEntityModified.ToolTip = CUtilities.LongDateTime(.EntityModified)
		End With
    End Sub
#End Region

#Region "Event Handlers"
    Private Sub chkEntityIsCached_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkEntityIsCached.CheckedChanged
        With m_entity
            .EntityIsCached = chkEntityIsCached.Checked
            .Save()
        End With
        Refresh()
    End Sub
	Private Sub chkEntityIsAudited_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkEntityIsAudited.CheckedChanged
		With m_entity
			.EntityIsAudited = chkEntityIsAudited.Checked
			.Save()
		End With
		Refresh()
	End Sub
#End Region

#Region "Private"
	Private Sub Refresh()
        'CCache.ClearCache()

        'If False Then 'Request.RawUrl.ToLower.Contains("myparent.aspx") Then
        '    'Special case: Parent entity owns the list
        '    Response.Redirect(CSitemap.MyParentEdit(m_entity.EntityParentId, MyParent.ETab.entitys, m_pageIndex)
        'Else
        '    'Normal case: Search page owns the list
            Response.Redirect(Request.RawUrl) 'includes paging info
        'End If 
    End Sub
#End Region

End Class
